﻿//Author:Michal Sporna
//License: https://operationsneakpeek.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Characters.Helpers
{
    /// <summary>
    /// Represents a pattern how the character is moving across the map cell
    /// </summary>
    public class MovePattern
    {
        #region properties
        public string NPCID;//which NPC
        public int NPCCT; //number
        public bool IsMoving;
        public int StartX;
        public int EndX;
        public int StartY;
        public int EndY;
        public double WaitTime;
        public Util.Helpers.PublicEnums.NPCMoveDirection MoveDirection;
        //list of master fields of view
        public List<Helpers.MasterFOV> FieldsOfView;

        #endregion

        #region helpers
        public string StartXString;
        public string EndXString;
        public string StartYString;
        public string EndYString;
        public string MoveDirectionString;
        public bool WellHiddenAcheivementDoneAlready; //if well hidden achievement was alredy done in this move pattern, then do not award points again
        #endregion


        #region methods

        /// <summary>
        /// Convert string values to numeric values
        /// </summary>
        public void ConvertMeasurements()
        {
            //declare
            Util.Helpers.Measurement msrmnt;

            try
            {
                //convert
                msrmnt = Util.Helpers.Utilities.ValidateAndConvertMeasurements(StartXString, StartYString, null, null);
                //assign
                this.StartX = msrmnt.X;
                this.StartY = msrmnt.Y;

                //end X, end Y
                msrmnt = Util.Helpers.Utilities.ValidateAndConvertMeasurements(EndXString,EndYString, null, null);
                //assign
                this.EndX = msrmnt.X;
                this.EndY = msrmnt.Y;

                //move direction
                switch (MoveDirectionString)
                {
                    case "Right":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.right;

                            break;
                        }
                    case "Left":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.left;

                            break;
                        }
                    case "Up":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.up;

                            break;
                        }
                    case "Down":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.down;

                            break;
                        }
                    case "CrossDownRight":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.crossDownRight;

                            break;
                        }
                    case "CrossDownLeft":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.crossDownLeft;

                            break;
                        }
                    case "CrossUpRight":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.CrossUpRight;

                            break;
                        }
                    case "CrossUpLeft":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.crossUpLeft;

                            break;
                        }
                    case "None":
                        {
                            this.MoveDirection = Util.Helpers.PublicEnums.NPCMoveDirection.None;

                            break;
                        }
                }

                //cleanup
                msrmnt = null;
                StartXString = null;
                StartYString = null;
                EndXString = null;
                EndYString = null;
            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }


        }


        /// <summary>
        /// Smoke a cigarrete, take a nap etc.
        /// </summary>
        public void HaveALife(Vector2 npcPosition)
        {
            try
            {
                //move avatar-must have trigger position
                //if trigger position is the same as npcPosition then do some action


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }


        }



        #endregion

    }
}
